commit: Display subject/body in commit editor
authorMathnerd314 <mathnerd314.gph+hs@gmail.com>
Mon, 23 May 2016 18:47:22 +0000 (12:47 -0600)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 25 May 2016 18:37:47 +0000 (18:37 +0000)
This allows automation to prefill the subject/body for the editor.

It could also be useful if some kind of "amend commit" functionality
was implemented.

Closes: #305
Approved by: cgwalters

src/ostree/ot-builtin-commit.c

index 5acd0243c456a29d0044addf67cf22ac5bc5b63d..99687c5262ed5755b49c9b5c1e982b38ed36ce2d 100644 (file)
@@ -218,14 +218,18 @@ commit_editor (OstreeRepo     *repo,
   char **lines = NULL;
   int i;
 
-  *subject = NULL;
-  *body = NULL;
-
   input = g_strdup_printf ("\n"
       "# Please enter the commit message for your changes. The first line will\n"
       "# become the subject, and the remainder the body. Lines starting\n"
       "# with '#' will be ignored, and an empty message aborts the commit."
-      "%s%s\n", branch ? "\n#\n# Branch: " : "", branch ?: "");
+      "%s%s%s%s%s%s\n"
+              , branch ? "\n#\n# Branch: " : "", branch ? branch : ""
+              , *subject ? "\n" : "", *subject ? *subject : ""
+              , *body ? "\n" : "", *body ? *body : ""
+              );
+
+  *subject = NULL;
+  *body = NULL;
 
   output = ot_editor_prompt (repo, input, cancellable, error);
   if (output == NULL)